// File resources for Win32
// Copyright 2006 (C) Ralph Thomas

#include <util/resources.h>
#include <windows.h>
#include <shlobj.h>
#include <boost/filesystem/operations.hpp>

namespace bfs = boost::filesystem;

namespace util {
	boost::filesystem::path getMissionPath() {
		//
		// The mission path is inside the user's Application Data
		// directory.
		//
		char path[MAX_PATH];
		if( SHGetFolderPath( 0, CSIDL_APPDATA, 0, SHGFP_TYPE_CURRENT, path ) != S_OK )
			throw std::runtime_error( "Can't get Application Data path" );
		bfs::path appData( path, bfs::native );
		appData /= "Mission";
		//
		// Verify that this path actually exists, and create it
		// if not.
		//
		if( !bfs::exists( appData ) ) bfs::create_directory( appData );
		return appData;
	}
	boost::filesystem::path getThumbnailPath() {
		//
		// The thumbnail path is inside the mission path on Windows.
		//
		bfs::path mpath( getMissionPath() );
		mpath /= "thumbnails";
		//
		// Create the thumbnail directory if it doesn't exist.
		//
		if( !bfs::exists( mpath ) ) bfs::create_directory( mpath );
		return mpath;
	}
}
